<?php
declare(strict_types=1);

namespace App\Resource\Group\Members;


use Illuminate\Http\Resources\Json\JsonResource;

class DetailResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            "id" => $this->user_id,
            "code" => empty($this->user->user_data->user_code) ? 0: $this->user->user_data->user_code,
            "nickname" => $this->nickname ?: $this->user->user_data->nickname,
            "avatar" => empty($this->user->user_data->head_picture) ? "" : $this->user->user_data->head_picture,
            "gender" => empty($this->user->user_data->sex) ? 0 : $this->user->user_data->sex,
            "signature" => empty($this->user->user_data->signature) ? "" : $this->user->user_data->signature,
            "role" => empty($this->user->user_data->role) ? 0 : $this->user->user_data->role,
            "background" => $this->background,
            "remark" => $this->remark,
            "group_role" => $this->role,
            "is_dnd" => $this->is_dnd,
            "is_follow" => $this->is_follow,
            "special" => $this->special,
            "grade_level" => empty($this->user->grade->grade) ? 0 : $this->user->grade->grade,
            "grade_icon" => empty($this->user->grade->head_picture) ? "" : $this->user->grade->head_picture,
            "guild_name" => $this->id,
            "guild_icon" => $this->id,
            "is_banned" => $this->is_banned,
            "banned_at" => $this->banned_at,
            "banned_countdown" => $this->banned_countdown,
            "last_chat_at" => $this->last_chat_at,
            "created_at" => $this->created_at->toDateTimeString(),
        ];
    }
}